<!DOCTYPE HTML>

<!--
Copyright 2014 Chris Devers

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<html>
 <head>
  <meta charset="UTF-8">
  <title>Follow Me - High Scores</title>
  <link rel="stylesheet" href="simon.css">
  
  <style type="text/css">
    /* The table undoes the body's margin attribute and replaces it with padding to make the table's width correct. */
    table {
        margin:  -8px;
        padding: 8px;
    }
    
    td, th {
        text-align: right;
    }
  </style>
 </head>
 
 <body>
  <!-- Import all of the game's other Javascript files. -->
  <script type="text/javascript" src="button_events.js"></script>
  
  <!-- High Score Screen -->
  <object data="images/back_button.svg" type="image/svg+xml" style="height:10%; width:10%"></object><br>
  
  <h1>High Scores</h1>
  
  <table style="width:100%">
   <thead>
    <tr>
     <th style="width:4em">Rank</th>
     <th>Name</th>
     <th>Score</th>
    </tr>
   </thead>
   <tbody id="highscore_table_body">
   </tbody>
  </table>
  
  <script type="text/javascript" src="cookies.js"></script>
  
  <script type="text/javascript">
    // The Back button should send the user back to the main menu.
    var prevPage, table, i, cookie, html;
    prevPage = "../simon.html";
    
    table = document.getElementById("highscore_table_body");
    for (i = 1; i <= MAX_NUM_HIGHSCORES; i += 1) {
        html = "<tr><td>" + i + "</td><td>";
        
        cookie = getHighScoreName(i);
        if (cookie === "") {
            html += "----";
        } else {
            html += cookie;
        }
        
        html += "</td><td>";
        
        cookie = getHighScore(i);
        if (cookie === "") {
            html += "0";
        } else {
            html += cookie;
        }
        
        html += "</td></tr>";
        
        table.innerHTML += html;
    }
  </script>
 </body>
</html>